package com.lhx.gmall.user.controller;

import com.lhx.gmall.bean.UmsMember;
import com.lhx.gmall.bean.UmsMemberReceiveAddress;
import com.lhx.gmall.service.UserService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class UserController {

    @Autowired
    UserService userService;

    @RequestMapping("index")
    @ResponseBody
    public String index(){
        return  "hello user";
    }


    //返回地址

    @RequestMapping("getReceiveAddressByMemberId")
    @ResponseBody
    public List<UmsMemberReceiveAddress> getReceiveAddressByMemberId(String memberId){

        List<UmsMemberReceiveAddress> umsMemberReceiveAddressList =  userService.getReceiveAddressByMemberId(memberId);



        //返回的为集合为json数据
        return   umsMemberReceiveAddressList;


    }

    //测试user类返回所有用户类型

    @RequestMapping("getAllUser")
    @ResponseBody
    public List<UmsMember> getAllUser(){

        List<UmsMember> umsMember =  userService.getAllUser();
        return  umsMember;


    }


}
